<style>
    table.table-form-title{margin:20px auto 0;}
    table.table-form-title td{text-align: center;border-bottom:0 !important;}
    table.table{width:90%;margin:0 auto;}
    table.table-form-attach{margin-bottom:100px;}
</style>
<div style="margin:0 auto;">
    <table class="table-form-title table" style="margin-top:20px;">
        <tr>
            <td colspan="4" style="border-bottom: 0 !important;">
                <h2>${config.getKey("COMPANY_NAME")}</h2>
                <h2>${bpmTaskFrom.fromName}</h2>
            </td>
        </tr>
        <tr>
            <td width="15%">NO：</td>
            <td width="45%"></td>
            <td width="15%"><span>金额单位：元</span></td>
        </tr>
    </table>
    <table class="table-form-head table table-hover table-bordered">
        <tr>
            <th>开具部门</th>
            <td>
                <@f.tableselect readonly=true checked=false value="${bpmForm.projectDept}" labelValue="${bpmForm.projectDept}"
                keyId="department" keyName="department" url="/bpm/project/list"
                name="projectDept" boxTitle="项目档案" tableInfo = "[{field:'name',title:'项目档案编号'},
                {field:'projectName',title:'项目名称'}, {field:'department',title:'项目所属部门'},{field:'ceoName',title:'项目经理'},
                {field:'contractFirst',title:'委托单位'},{field:'createTime',title:'创建时间'}]" placeholder="请选择项目档案编号" />
            </td>
            <th>合作项目经理</th>
            <td>
                <!--<input class="form-control" name="ceoName" value="" type="text"  >-->
                <@f.tableselect readonly=true name="cooperatAdmin" value="${bpmForm.cooperatAdmin}"
                labelValue="${bpmForm.cooperatAdmin}" boxTitle="请选择申请人" checked=false
                tableInfo = "[{field:'username',title:'账号'},{field:'name',title:'姓名',query:
                true},{field:'compName',title:'归属公司'},
                {field:'deptName',title:'归属机构'},{field:'email',title:'邮箱'},{field:'mobile',title:'手机号码'},
                {field:'status',title:'状态',dict:'sys_user_show_hide',query: true},{field:'createTime',title:'创建时间'}]"
                placeholder="表格弹出式页面，实用于大数据，搜索选择，" />
                <div id="c_tableselect" class="panel-collapse collapse"></div>
            </td>
        </tr>
        <tr>
            <th>发起日期</th>
            <td>
                <@f.input readonly=true name="createTime" value="${bpmForm.createTime?string('yyyy-MM-dd')}" type="date"
                dataType="date" dataFormat="yyyy-MM-dd"
                placeholder="发起日期" butClass="fa fa-calendar-plus-o" required=true />
            </td>
            <th>项目经理</th>
            <td>
                <!--<input class="form-control" name="ceoName" value="" type="text"  >-->
                <@f.tableselect readonly=true name="projectAdmin" value="${bpmForm.projectAdmin}" labelValue="${bpmForm.projectAdmin}"
                boxTitle="请选择申请人" checked=false
                tableInfo = "[{field:'username',title:'账号'},{field:'name',title:'姓名',query:
                true},{field:'compName',title:'归属公司'},
                {field:'deptName',title:'归属机构'},{field:'email',title:'邮箱'},{field:'mobile',title:'手机号码'},
                {field:'status',title:'状态',dict:'sys_user_show_hide',query: true},{field:'createTime',title:'创建时间'}]"
                placeholder="表格弹出式页面，实用于大数据，搜索选择，" />
                <div id="c_tableselect2" class="panel-collapse collapse"></div>
            </td>
        </tr>
    </table>
    <table class="table-form-body table table-hover table-bordered">
        <thead>
        <tr>
            <td colspan="9">
                <button name="btn-insert" type="button" class="btn btn-primary btn-rounded btn-sm">插入行</button>
                <button name="btn-copy" type="button" class="btn btn-primary btn-rounded btn-sm">复制行</button>
                <button name="btn-del" type="button" class="btn btn-primary btn-rounded btn-sm">删除行</button>
                <button name="btn-del-all" type="button" class="btn btn-primary btn-rounded btn-sm">删除全部</button>
                <button name="btn-import" type="button" class="btn btn-primary btn-rounded btn-sm">导入数据</button>
            </td>
        </tr>
        <tr>
            <th>工作方法</th>
            <th>单价</th>
            <th>数量</th>
            <th>应交款</th>
        </tr>
        </thead>
        <tbody name="items">
        <tr data-id="">
            <td>
                <@f.input readonly=true name="method" value="${bpmForm.method}" placeholder="" required=true/>
            </td>
            <td>
                <@f.input readonly=true name="unitPrice" value="${bpmForm.unitPrice}" placeholder="" required=true/>
            </td>
            <td>
                <@f.input readonly=true name="count" value="${bpmForm.count}" placeholder="" required=true/>
            </td>
            <td>
                <@f.input readonly=true name="price" value="${bpmForm.price}" placeholder="" required=true/>
            </td>
        </tr>
        </tbody>
    </table>
    <table class="table-form-head table table-hover table-bordered">
        <tr>
            <th>合计</th>
            <td colspan="3">
                <@f.input readonly=true name="amount" value="${bpmForm.amount}" placeholder="" required=true/>
            </td>
        </tr>
        <tr>
            <th>年月</th>
            <td>
                <@f.input readonly=true name="month" value="${bpmForm.month}" type="date" dataType="date" dataFormat="yyyy年MM月"
                placeholder="年月" butClass="fa fa-calendar-plus-o" required=true />
            </td>
            <th>制单人</th>
            <td>
                <!--<input class="form-control" name="ceoName" value="" type="text"  >-->
                <@f.tableselect readonly=true name="launchName" value="${bpmForm.launchName}" labelValue="${bpmForm.launchName}"
                boxTitle="请选择申请人" checked=false
                tableInfo = "[{field:'username',title:'账号'},{field:'name',title:'姓名',query:
                true},{field:'compName',title:'归属公司'},
                {field:'deptName',title:'归属机构'},{field:'email',title:'邮箱'},{field:'mobile',title:'手机号码'},
                {field:'status',title:'状态',dict:'sys_user_show_hide',query: true},{field:'createTime',title:'创建时间'}]"
                placeholder="表格弹出式页面，实用于大数据，搜索选择，" />
                <div id="c_tableselect3" class="panel-collapse collapse"></div>
            </td>
        </tr>
        <tr>
            <th>备注</th>
            <td colspan="3">
                <@f.input readonly=true name="remark" value="${bpmForm.remark}" placeholder="备注" required=true/>
            </td>
        </tr>
        <tr>
            <th>处理意见</th>
            <td colspan="3">
                <@f.input readonly=true name="opinion" value="${bpmForm.opinion}" placeholder="处理意见" required=true/>
            </td>
        </tr>
    </table>
</div>

<script type="text/javascript">
    function showFileDlg() {
        $("#file").click();
    }
    $("#file").change(function () {
        uploadBidedNotice();
    });
    function uploadBidedNotice() {
        var oFiles = document.getElementById("file").files;
        console.log(oFiles);
        var formdata = new FormData();
        formdata.append("file", oFiles[0]);
        opt.common.sendAjax({
            url: prefix + "/doUploadFile",
            data: formdata,
            type: "POST",
            processData: false,
            contentType: false,
            success: function(result) {
                console.log(result);
                if (result.status==0){
                    alert("请上传正确的照片格式！！")
                } else{
                    $("input[name=photoContent]").val(oFiles[0].name);
                    $("input[name=photoUrl]").attr("value",baseURL + result.url);
                    $("a[name=bidedNoticeBox]").html(oFiles[0].name).attr("href",baseURL + result.url);
                }
            }
        })
    }

    function showFileDlg2() {
        $("#file2").click();
    }
    $("#file2").change(function () {
        uploadBidedNotice2();
    });
    function uploadBidedNotice2() {
        var oFiles = document.getElementById("file2").files;
        console.log(oFiles);
        var formdata = new FormData();
        formdata.append("file2", oFiles[0]);
        opt.common.sendAjax({
            url: prefix + "/doUploadFile2",
            data: formdata,
            type: "POST",
            processData: false,
            contentType: false,
            success: function(result) {
                console.log(result);
                if (result.status==0){
                    alert("请上传正确格式的电子档工程概况表！！")
                } else{
                    $("input[name=projectInfoContent]").val(oFiles[0].name);
                    $("input[name=projectInfoUrl]").attr("value",baseURL + result.url);
                    $("a[name=bidedNoticeBox2]").html(oFiles[0].name).attr("href",baseURL + result.url);
                }
            }
        })
    }

    function tableCallback(id, event, index, layero, nodes){
        console.log("aaaaaaaaaaaaaaa")
        if(id == "launchName"){
            console.log("弹出表格选择===>>>>: id:" + id + "  event:" + event + " index:" + index + "  layero:"+ layero + " nodes:" + JSON.stringify(nodes));
            console.log(nodes.table[0]);
            var data = nodes.table[0];
            console.log(data)

            console.log(data.ceoName);
            $("input[name=launchDepartment]").val(data.compName);
            //  $("input[name=projectName]").val(data.projectName);
            // // $("input[name=ceoName]").val(data.ceoName);
            //  $("input[name=projectAdmin]").val(data.ceoName);
            //  $("input[name=clientCompany]").val(data.contractFirst);
            //  $("input[name=projectDept]").val(data.department);
        }
    }


    $("button[name=btn-insert]").click(function () {
        var target = $(this).closest("table").find("tbody");
        var index = target.children().length + 1;
        var tpl = $(target.children().get(0)).prop("outerHTML");
        tpl = tpl.replaceAll("1", index);
        target.append(tpl);
    });
    $("button[name=btn-del]").click(function () {
        var target = $(this).closest("table").find("tbody");
        var index = target.children().length - 1;
        if(index>0){
            target.children().get(index).remove();
        }
    });
    $("button[name=btn-del-all]").click(function () {
        var target = $(this).closest("table").find("tbody");
        var index = target.children().length - 1;
        for(var i=index; i>0; i--){
            target.children().get(i).remove();
        }
    });
</script>